<?php
namespace Home\Model;
use Think\Model;
class LoginModel extends Model{
    protected $tableName = 'yh_admin';
    public function login($username,$pwd){
        if(!empty($username)&&!empty($pwd)){
            $User = M($this->tableName);
            $arr = $User->where("username = '$username'")->select();
            if($arr){
                $pwd1 = $arr[0]['password'];
                $hash = password_hash($pwd,PASSWORD_DEFAULT);
                $res = password_verify($pwd1,$hash);
                if($res){
                    return true;
                }
            }
        }
        return false;
    }
    public function logout(){
        session_destroy();
        return true;
    }
}